import os
import xml.etree.ElementTree as ET

xml_folder = r'C:\Users\Administrator\Desktop\shuju\zhw\xml'

for file_name in os.listdir(xml_folder):
    if file_name.endswith('.xml'):
        xml_path = os.path.join(xml_folder, file_name)
        tree = ET.parse(xml_path)
        root = tree.getroot()
        
        for obj in root.findall('object'):
            name = obj.find('name').text
            if name.startswith('Q'):
                print('find1')
                obj.find('name').text = 'QRcode'
            elif name.startswith('B'):
                print('find2')
                obj.find('name').text = 'BarCode'

        tree.write(xml_path)
